package top.lingkang.finaloauth.server.base.impl;

import top.lingkang.finaloauth.entity.OauthClient;
import top.lingkang.finaloauth.server.base.ClientRepository;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lingkang
 * Created by 2022/3/18
 */
public class MemoryClientRepository implements ClientRepository {
    private Map<String, OauthClient> map = new HashMap<>();

    @Override
    public OauthClient get(String client_id, String client_secret) {
        return map.get(client_id + "-" + client_id);
    }

    @Override
    public void add(OauthClient client) {
        map.put(client.getClientId() + "-" + client.getClientSecret(), client);
    }

    @Override
    public OauthClient delete(String client_id, String client_secret) {
        return map.remove(client_id + "-" + client_id);
    }
}
